package com.example.routingapp_exercise;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class SettingActivity extends Activity {

	private EditText from;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);
		
		from = (EditText) findViewById(R.id.editFrom);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_setting, menu);
		return true;
	}
	
	public void saveSetting(View v){
		//MEldung ausgeben
		Toast t = Toast.makeText(this, "Saving Settings", Toast.LENGTH_LONG);		
		t.show();
		
		SharedPreferences sharedPref = getSharedPreferences("setting", 0);
		
		SharedPreferences.Editor editor = sharedPref.edit();
		editor.putString("from", from.getText().toString());
		editor.commit();
		
		Toast.makeText(this, "Saved", Toast.LENGTH_LONG).show();
		        
		
	}
	
	public void loadSetting(View v){
		Toast.makeText(this, "load Settings", Toast.LENGTH_LONG).show();
		
		SharedPreferences sharedPref = getSharedPreferences("setting", 0);
		String s = sharedPref.getString("from", "");
		
		from.setText(s);

	}

}
